package com.tina.mapper;

import com.tina.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Tina
 * @since 2020-07-01
 */
@Repository
public interface EmployeeMapper {
    /**
     * 查询全部员工
     *
     * @return
     */
    @Select("select emp_id,emp_name,emp_age,emp_sex,emp_address from  employee")
    public List<Employee> empList();

    /**
     * 新增员工
     *
     * @param emp
     * @return
     */
    @Insert("insert into employee(emp_name,emp_age,emp_sex,emp_address) value(#{empName},#{empAge},#{empSex},#{empAddress})")
    public Integer saveEmp(Employee emp);

    /**
     * 删除员工
     *
     * @param empId
     * @return
     */
    @Delete("delete from employee where emp_id=#{empId}")
    public Integer delEmp(Integer empId);

    /**
     * 编辑员工
     *
     * @param emp
     * @return
     */
    @Update("update employee set emp_name=#{empName},emp_age=#{empAge},emp_sex=#{empSex},emp_address=#{empAddress} where emp_id=#{empId}")
    public Integer editEmp(Employee emp);
}
